#!/usr/bin/env bash
set -ex

cd $(dirname $0)/..

source ./scripts/version.sh
export DOCKER_CLI_EXPERIMENTAL=enabled

set +x
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
set -x

docker buildx imagetools create \
    --tag ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION} \
    ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-linux-amd64 \
    ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-linux-arm64 \
    ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION}-windows-amd64

if [ -n "${IID_FILE}" ]; then
    docker buildx imagetools inspect --format "{{json .Manifest}}" ${REPO}/${PROG}-runtime:${DOCKERIZED_VERSION} | jq -r '.digest' > ${IID_FILE}
fi
